package com.annhoa.ribbon;

/**
 * @Author annhoa
 * @Date 2019/3/18 11 00
 * @Description
 */

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @description 添加熔断机制
 * @author  annhoa
 */
@Service
public class OfferServeRibbon {
    @Autowired
    RestTemplate restTemplate;

    public String hiError1() {
        return "sorry text1,Ribbon error!";
    }
    public String hiError2() {
        return "sorry text2,Ribbon error!";
    }
    @HystrixCommand(fallbackMethod = "hiError1")
    String text1(){
        return restTemplate.getForObject("http://offer/index/text1",String.class);
    }
    @HystrixCommand(fallbackMethod = "hiError2")
    String text2(){
        return restTemplate.getForObject("http://offer/index/text2",String.class);
    }




}
